//
//  LPNewFeatureViewCell.m
//  彩票
//
//  Created by liupan on 2016/12/5.
//  Copyright © 2016年 liupan. All rights reserved.
//

#import "LPNewFeatureViewCell.h"
#import "LPTabBarController.h"
@interface LPNewFeatureViewCell ()
/** 背景图片的View*/
@property (nonatomic,weak)UIImageView *bgImageView;
/** 立即体验 */
@property (nonatomic,weak)UIButton *starBtn;
@end
@implementation LPNewFeatureViewCell
//懒加载
- (UIImageView *)bgImageView{

    if (!_bgImageView) {
        UIImageView *bgImageView = [[UIImageView alloc]initWithFrame:self.bounds];
        [self.contentView addSubview:bgImageView];
        _bgImageView = bgImageView;
    }
     return _bgImageView;
}
//创建立即体验按钮
- (UIButton *)starBtn{

    if (!_starBtn) {
        UIButton *starBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [starBtn setBackgroundImage:[UIImage imageNamed:@"guideStart"] forState:UIControlStateNormal];
        [starBtn sizeToFit];
        [starBtn addTarget:self action:@selector(start) forControlEvents:UIControlEventTouchUpInside];
        starBtn.center = CGPointMake(self.width * 0.5,self.height * 0.9);
        _starBtn = starBtn;
        [self.contentView addSubview:_starBtn];
    }
    return _starBtn;
}
- (void)start{

    // 跳转到核心界面,push,modal,切换跟控制器的方法
    [UIApplication sharedApplication].keyWindow.rootViewController = [[LPTabBarController alloc]init];
    
    CATransition *anim = [CATransition animation];
    anim.type = @"rippleffect";
    [[UIApplication sharedApplication].keyWindow.layer addAnimation:anim forKey:nil];
}
//重写image set方法
- (void)setImage:(UIImage *)image{

    _image=image;
    self.bgImageView.image = image;
}
- (void)setupIndex:(NSIndexPath *)indexPath count:(NSInteger)pagecount{

    //判断是最后一行
    if (indexPath.row == pagecount -1) {
        self.starBtn.hidden = NO;
    }else{
        self.starBtn.hidden = YES;
    }
}
@end
